<template>
  <div class="join-url-container">
    <div class="main-content-flex">
      <div class="background-animation"></div>
      <div class="logo-container">
        <img src="@/assets/images/newlog.png" alt="富创云会议" class="logo" />
        <span class="logo-text">富创云会议</span>
      </div>
      <div class="join-content-wrapper">
        <div class="join-content">
          <h1>会议服务项</h1>
          <div class="meeting-info">
            <div v-if="loading" class="info-item">
              <span class="label">服务项：</span>
              <span class="value">加载中...</span>
            </div>
            <div v-else-if="errorMsg" class="info-item">
              <span class="label">服务项：</span>
              <span class="value" style="color: #e53e3e">{{ errorMsg }}</span>
            </div>
            <template v-else>
              <div v-for="(item, idx) in serveList" :key="idx" class="info-item" style="flex-direction: column; align-items: flex-start; width: 100%;">
                <div style="font-weight: 600; color: #1e3a8a; margin-bottom: 2px; font-size: 17px;">
                  {{ item.name }}
                </div>
                <div v-if="item.serve && item.serve.length" style="width: 100%; margin-bottom: 2px;">
                  <div v-for="(serve, sidx) in item.serve" :key="sidx" style="margin-left: 12px; color: #1e40af; font-size: 15px; line-height: 1.8;">
                    {{ sidx + 1 }}. {{ serve }}
                  </div>
                </div>
                <div v-if="item.otherServe && item.otherServe.length" style="margin-top: 2px; width: 100%;">
                  <span class="label" style="width:auto;">其他服务：</span>
                  <span class="value">{{ item.otherServe.join('，') }}</span>
                </div>
              </div>
            </template>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import request from '@/utils/request'

interface MeetServeVO {
  name: string
  serve: string[]
  otherServe: string[]
}

const route = useRoute()
const conferenceId = ref<string>('')
const serveList = ref<MeetServeVO[]>([])
const loading = ref(false)
const errorMsg = ref('')

const getServeList = async () => {
  loading.value = true
  errorMsg.value = ''
  try {
    const id = route.query.conferenceId as string
    if (!id) {
      errorMsg.value = '缺少会议号'
      loading.value = false
      return
    }
    conferenceId.value = id
    const res = await request.get('/wecom/getServeList', {
      params: { conferenceId: id }
    })
    serveList.value = res.data || []
    if (!Array.isArray(serveList.value) || serveList.value.length === 0) {
      errorMsg.value = '暂无服务项信息'
    }
  } catch (e) {
    errorMsg.value = '获取服务项失败'
  } finally {
    loading.value = false
  }
}

onMounted(() => {
  getServeList()
})
</script>

<style scoped>
.join-url-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
  background: #f6f8fa;
  position: relative;
  overflow: hidden;
}
.main-content-flex {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  position: relative;
}
.join-content-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.background-animation {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(-45deg, #1e3a8a, #3b82f6, #60a5fa, #93c5fd);
  background-size: 400% 400%;
  animation: gradient 15s ease infinite;
  z-index: 0;
}
@keyframes gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}
.logo-container {
  position: fixed;
  top: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 2;
}
.logo {
  width: 32px;
  height: 32px;
}
.logo-text {
  color: #ffffff;
  font-size: 20px;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.join-content {
  background: rgba(255, 255, 255, 0.95);
  padding: 3rem;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 800px;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(10px);
}
h1 {
  text-align: center;
  margin-bottom: 3rem;
  color: #1e3a8a;
  font-size: 32px;
  font-weight: 600;
}
.meeting-info {
  margin-bottom: 3rem;
  padding: 2rem;
  background-color: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.1);
  max-height: 88vh; /* 再次提高最大高度 */
  overflow-y: auto;
}
.info-item {
  margin: 1rem 0;
  display: flex;
  align-items: center;
  border-bottom: 2px solid #3b82f6; /* 分隔线更浅蓝色 */
  padding-bottom: 0.5rem;
}
.info-item:last-child {
  border-bottom: none;
}
.label {
  color: #1e3a8a;
  width: 100px;
  flex-shrink: 0;
  font-weight: 500;
  font-size: 16px;
}
.value {
  color: #1e40af;
  flex: 1;
  font-size: 16px;
}
@media (max-width: 600px) {
  .join-url-container {
    min-height: 100vh !important;
    height: 100vh !important;
    padding: 0 !important;
    overflow: hidden !important;
  }
  .main-content-flex {
    height: 100%;
    min-height: 0;
  }
  .join-content-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 0 !important;
  }
  .logo-container {
    position: static !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    align-items: center !important;
    margin-bottom: 6px !important;
    width: 100% !important;
    gap: 4px !important;
    padding-left: 8px !important;
    height: 38px !important;
  }
  .logo {
    width: 22px !important;
    height: 22px !important;
  }
  .logo-text {
    font-size: 15px !important;
    color: #1e3a8a !important;
    text-shadow: none !important;
    font-weight: 700 !important;
  }
  .join-content {
    padding: 0.7rem 0.3rem 0.7rem 0.3rem !important;
    max-width: 98vw !important;
    min-width: 0 !important;
    border-radius: 10px !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04) !important;
    margin: 0 auto 6px auto !important;
    margin-top: 2vw !important;
  }
  .meeting-info {
    padding: 0.5rem 0.2rem 0.5rem 0.2rem !important;
    margin-bottom: 0.7rem !important;
    font-size: 15px !important;
    border-radius: 8px !important;
    background: #fafdff !important;
    border: 1px solid #e3e8ee !important;
    box-shadow: 0 1px 2px rgba(30,58,138,0.02) !important;
    max-height: 80vh !important; /* 手机端更高 */
    overflow-y: auto !important;
  }
  .info-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    margin: 0.5rem 0 0.5rem 0 !important;
    padding-bottom: 0.3rem !important;
    border-bottom: 2px solid #3b82f6 !important; /* 分隔线更浅蓝色 */
    width: 100% !important;
    font-size: 14px !important;
  }
  .info-item:last-child {
    border-bottom: none !important;
  }
  .label {
    font-size: 14px !important;
    width: auto !important;
    margin-bottom: 1px !important;
    color: #1e3a8a !important;
    font-weight: 600 !important;
  }
  .value {
    font-size: 14px !important;
    word-break: break-all !important;
    color: #1e40af !important;
    margin-bottom: 2px !important;
  }
  h1 {
    font-size: 17px !important;
    margin-bottom: 0.7rem !important;
    text-align: center !important;
    color: #1e3a8a !important;
    font-weight: 700 !important;
  }
}
</style>
